package vn.ikame.android.boojtran.truyenbua;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import vn.ikame.android.boojtran.truyenbua.object.GA;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;

public class Exit extends SuperActivity implements Runnable {
	public static final int EXIT_DELAY = 1;

	private ScheduledExecutorService executor;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.exit);
		executor = Executors.newSingleThreadScheduledExecutor();
		executor.schedule(this, EXIT_DELAY, TimeUnit.MILLISECONDS);
	}

	@Override
	public void onDestroy() {
		GA.stopDetail();
		super.onDestroy();
	}

	public void nextScreen() {
		try {
			// if (noti.getType() == 3 && !noti.isShow()) {
			// noti.createNotificationAlert(Exit.this);
			// } else {
			finish();
			System.gc();
			executor.shutdown();
			// android.os.Process.killProcess(android.os.Process.myPid());
			Intent intent = new Intent(Intent.ACTION_MAIN);
			intent.addCategory(Intent.CATEGORY_HOME);
			intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(intent);
			finish();
			System.exit(0);
			// }

		} catch (Exception e) {
		}
	}

	@Override
	public void run() {
		nextScreen();
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		return true;
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		return true;
	}
}
